<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core">
    <!--开始 文章列表-->
    <script>$('.left-siderbar-all-text').addClass('active');</script>
    <h3>所有文章</h3>
    <div class="table-responsive">
        <table class="table table-striped table-hover table-bordered">
            <thead>
            <tr>
                <th>序号</th>
                <th>标题</th>
                <th>作者</th>
                <th>分类</th>
                <th>状态</th>
                <th>浏览量</th>
                <th>评论</th>
                <c:if test="#{userBean.currentUser.status eq 0}">
                    <th>操作</th>
                </c:if>
            </tr>
            </thead>
            <tbody>
            <c:set var="index" value="0"/>
            <c:forEach items="#{postBean.allTextPost}" var="text">
                <c:set var="index" value="${index+1}"/>
                <tr>
                    <td>${index}</td>
                    <td><h:link outcome="/article?id=${text.id}" value="${text.title}"/></td>
                    <td>${text.author.username}</td>
                    <td>${text.category.name}</td>
                    <td>
                        <c:choose>
                            <!--0发表 1草稿-->
                            <c:when test="${text.status eq 0}">
                                发表于${text.publishDate}
                            </c:when>
                            <c:when test="${text.status eq 1}">
                                草稿
                            </c:when>
                        </c:choose>
                    </td>
                    <td>${text.hint}</td>
                    <c:set var="allowComment" value="评论已关闭"/>
                    <c:choose>
                        <c:when test="${text.allowComment}">
                            <c:set value="允许评论" var="allowComment"/>
                        </c:when>
                    </c:choose>
                    <td>
                        <c:choose>
                            <c:when test="${text.commentCount eq 0}">
                                ${allowComment} | 暂无评论
                            </c:when>
                            <c:otherwise>
                                ${allowComment} | 有${text.commentCount}条评论
                            </c:otherwise>
                        </c:choose>
                    </td>
                    <c:if test="#{userBean.currentUser.status eq 0}">
                        <td>
                            <h:form>
                                <input type="hidden" name="id" value="${text.id}"/>
                                <h:commandLink action="#{postBean.toUpdatePostPage}" value="编辑"/> |
                                <h:commandLink action="#{postBean.delete}" value="删除"/>
                            </h:form>
                        </td>
                    </c:if>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
    <!--结束 文章列表-->
</ui:composition>